Skip to content

fix: manual edits inside positioned group should use absolute manual center#2565

Open
r-audio wants to merge 1 commit into
tscircuit:mainfrom
r-audio:fix/manual-edits-group-anchor-double-count
Open

fix: manual edits inside positioned group should use absolute manual center#2565
r-audio wants to merge 1 commit into
tscircuit:mainfrom
r-audio:fix/manual-edits-group-anchor-double-count

Conversation

@r-audio

@r-audio r-audio commented Jul 3, 2026

Copy link
Copy Markdown

Problem

When a component is placed via manualEdits with relative_to: "group_center" inside a <group> that has pcbX/pcbY offsets, the parent group's transform is applied twice — once inside _getPcbManualPlacementForComponent() (which already returns the absolute PCB center) and again when composing with this.parent?._computePcbGlobalTransformBeforeLayout().

This causes components to land at parent_offset + manual_placement instead of the intended absolute position.

Reproduction: placing a capacitor at { x: 11.4, y: 4.3 } inside a group with pcbX=16 yields x=27.4 instead of x=11.4.

Fix

Remove the parent transform composition from _computePcbGlobalTransformBeforeLayout() when manual placement is active. The manual placement already returns absolute coordinates, so the parent transform should not be re-applied.

- this.parent?._computePcbGlobalTransformBeforeLayout() ?? identity(),
- compose(
-   translate(manualPlacement.x, manualPlacement.y),
-   rotate((rotation * Math.PI) / 180),
- ),
+ translate(manualPlacement.x, manualPlacement.y),
+ rotate((rotation * Math.PI) / 180),

Verification

bun test \
  tests/components/normal-components/manual-placement-conflicts.test.tsx \
  tests/components/normal-components/manual-edit-conflict-warning-2.test.tsx \
  tests/components/normal-components/board-layout.test.tsx \
  tests/components/primitive-components/group-anchor-position.test.tsx

Result: 9 pass, 0 fail (1 snapshot, 22 expect() calls)

New test manual layout edits inside positioned group use absolute manual center verifies the fix directly by asserting the capacitor lands at the intended (11.4, 4.3) position.

Fixes #2281

…center

_getPcbManualPlacementForComponent() already returns the absolute PCB
center, so composing it with the parent group's transform double-counted
the parent offset. This caused components placed via manualEdits inside a
group with pcbX/pcbY to land at parent_offset + manual_placement instead
of the intended absolute position.

Fixes tscircuit#2281
@vercel

vercel Bot commented Jul 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tscircuit-core-benchmarks Ready Ready Preview, Comment Jul 3, 2026 12:15am

Request Review

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown

This PR has been automatically marked as stale because it has had no recent activity. It will be closed if no further activity occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

manualEdits position double-counts the parent group's anchor for components inside positioned regions

1 participant